﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;

using ZoneFiveSoftware.Common.Data;
using ZoneFiveSoftware.Common.Data.Fitness;
using ZoneFiveSoftware.Common.Data.GPS;
using ZoneFiveSoftware.Common.Visuals;
using ZoneFiveSoftware.Common.Visuals.Fitness;

namespace GearChart.UI.DetailPage
{
    class GearChartPage : IActivityDetailPage
    {
        #region IActivityDetailPage Members

        public IActivity Activity
        {
            set
            {
                // Called everytime selected activity is changed
                activity = value;
                if (loaded)
                {
                    // Refresh page if this is the selected view
                    control.Activity = activity;
                    control.RefreshPage();
                }
            }
        }

        public void RefreshPage()
        {

        }

        #endregion

        #region IDialogPage Members

        public System.Windows.Forms.Control CreatePageControl()
        {
            if (control == null)
            {
                instance = this;
                control = new GearChartDetail();
                control.Activity = activity;
                PropertyChanged += new PropertyChangedEventHandler(GearChart_PropertyChanged);
            }
            return control;
        }

        public bool HidePage()
        {
            // View is no longer active
            loaded = false;
            return true;
        }

        public string PageName
        {
            get
            {
                return Resources.Strings.GearSelection;
            }
        }

        public void ShowPage(string bookmark)
        {
            loaded = true;
            control.RefreshPage();
        }

        public IPageStatus Status
        {
            get { return null; }
            set { }
        }

        public void ThemeChanged(ITheme visualTheme)
        {
            control.ThemeChanged(visualTheme);
        }

        public string Title
        {
            get { return Resources.Strings.GearSelection; }
        }

        public void UICultureChanged(System.Globalization.CultureInfo culture)
        {
            
        }

        #endregion

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        void GearChart_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            throw new NotImplementedException();
        }

        #endregion

        public static GearChartPage Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new GearChartPage();
                }

                return instance;
            }
        }

        private static IActivity activity;
        private static GearChartDetail control;
        private static Boolean loaded;
        private static GearChartPage instance;
    }
}
